﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using com.fmtx.IDal;
using com.fmtx.Model;
using fmtx.Framework.DALFactory;

namespace website.Areas.Website.Controllers
{
    public class PhotoController : BaseController
    {
        //
        // GET: /Website/Photo/
        private IArticle article = DataAccess<IArticle>.GetObject();
        private IPictureType pictureType = DataAccess<IPictureType>.GetObject();
        private IPicture picture = DataAccess<IPicture>.GetObject();
        private IUserInfo user = DataAccess<IUserInfo>.GetObject();
        private IKeyWord keyword = DataAccess<IKeyWord>.GetObject();

        public ActionResult Index()
        {
            List<OutPut> models = PictureCache.Query(0, 24,null);
            if (models.Count > 0)
            {
                ViewBag.lastid = models.LastOrDefault().Id;
            }
            ViewBag.Keywords = keyword.QueryHost(40,Target.PICTRUE);
            return View(models);
        }

        /// <summary>
        /// 单个图片
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Detail(int id)
        {
            var model = picture.Get(id);
            StaticCs.SetShowPictureCount(id);
            var type = pictureType.Get(model.TypeId);
            ViewBag.bean=type;
            ViewBag.user = user.Get(model.Uid);
            var models = picture.QueryByUser(model.Uid, model.TypeId);

            ViewBag.newlist = article.QueryNew(5);
            ViewBag.hostlist = article.QueryHost(5);
            ViewBag.ulist = user.QueryArticleCount(12);
            ViewBag.xgarticle = article.Query(5, model.Uid,model.Address);
            return View(models);
        }

    }
}
